﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Library.Components;
using NCS.Library.Utilities;
using NCS.Module.CMS.Library;
using NCS.Module.CMS.Library.Zones;
using NCS.Library;

namespace NCS.Module.CMS.Web.Sport
{
    public partial class NavBar : CMSWebControl
    {
        protected string lblMenu = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            int zoneactive = ConvertUtility.ToInt32(Portal[Definition.Portal_Zone_Active + "_" + AppEnv.PortalId() + "_" + AppEnv.GetLanguage()]);

            DataTable dt = ZoneController.GetZonesVisbleInTab();
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                if (ConvertUtility.ToInt32(dt.Rows[i]["Zone_ID"]) == ConvertUtility.ToInt32(Request.QueryString["catid"]))
                {
                    if (i == 0)
                    {
                        lblMenu += "<li>";
                        lblMenu += " <a href='" + BuildUrlbyPortal() + "'>" + ConvertUtility.ToString(dt.Rows[i]["Zone_Name"]) + "</a>";
                        lblMenu += "</li>";
                    }
                    else
                    {
                        lblMenu += "<li class=\"first selected\">";
                        lblMenu += " <a href='" + BuildUrlByZone(ConvertUtility.ToInt32(dt.Rows[i]["Zone_ID"]), ConvertUtility.ToInt32(dt.Rows[i]["Portal_TabControlID"])) + "'>" + ConvertUtility.ToString(dt.Rows[i]["Zone_Name"]) + "</a>";
                        lblMenu += "</li>";
                    }
                }
                else
                {
                    if (ConvertUtility.ToInt32(Request.QueryString["catid"]) == 0 && ConvertUtility.ToInt32(dt.Rows[i]["Zone_ID"]) == zoneactive)
                    {
                        lblMenu += "<li class=\"first selected\">";
                        lblMenu += " <a href='" + BuildUrlbyPortal() + "'>" + ConvertUtility.ToString(dt.Rows[i]["Zone_Name"]) + "</a>";
                        lblMenu += "</li>";
                    }
                    else
                    {
                        if (ConvertUtility.ToInt32(dt.Rows[i]["Zone_ID"]) == zoneactive)
                        {
                            lblMenu += "<li>";
                            lblMenu += " <a href='" + BuildUrlbyPortal() + "'>" + ConvertUtility.ToString(dt.Rows[i]["Zone_Name"]) + "</a>";
                            lblMenu += "</li>";
                        }
                        else
                        {
                            lblMenu += "<li>";
                            lblMenu += " <a href='" + BuildUrlByZone(ConvertUtility.ToInt32(dt.Rows[i]["Zone_ID"]), ConvertUtility.ToInt32(dt.Rows[i]["Portal_TabControlID"])) + "'>" + ConvertUtility.ToString(dt.Rows[i]["Zone_Name"]) + "</a>";
                            lblMenu += "</li>";
                        }

                        if (i > 0)
                        {
                            if (i < dt.Rows.Count - 1)
                            {
                                if (ConvertUtility.ToInt32(dt.Rows[i - 1]["Zone_ID"]) != ConvertUtility.ToInt32(Request.QueryString["catid"]) && ConvertUtility.ToInt32(dt.Rows[i + 1]["Zone_ID"]) != ConvertUtility.ToInt32(Request.QueryString["catid"]))
                                {
                                    lblMenu += "<font color=\"#ABC777\">|</font>";
                                }
                            }
                        }
                        else
                        {
                            if (ConvertUtility.ToInt32(dt.Rows[i + 1]["Zone_ID"]) != ConvertUtility.ToInt32(Request.QueryString["catid"]))
                            {
                                lblMenu += "<font color=\"#ABC777\">|</font>";
                            }
                        }
                    }

                }
            }
        }
    }
}